Account for the fact that Xlib expects format == 32 to be a long, even on
authorOwen Taylor <otaylor@redhat.com>
Sun, 21 Feb 1999 20:55:04 +0000 (20:55 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Sun, 21 Feb 1999 20:55:04 +0000 (20:55 +0000)
Sun Feb 21 15:59:55 1999  Owen Taylor  <otaylor@redhat.com>

* gdk/MwmUtil.h gdk/gdkwindow.c: Account for the
fact that Xlib expects format == 32 to be a long,
even on 64-bit architectures.

[ patch from George Lebl (jirka@5z.com) ]

16 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/MwmUtil.h
gdk/gdk.c
gdk/gdk.h
gdk/gdkwindow.c
gdk/x11/MwmUtil.h
gdk/x11/gdkmain-x11.c
gdk/x11/gdkwindow-x11.c
gtk/gtkmain.c
gtk/gtkmain.h

index 7ccbb7706ef5d5b9e4a72a0f62516244546e3506..0d870f6b055b37b1af07c8dd6a0722387f44a405 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+Sun Feb 21 15:59:55 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/MwmUtil.h gdk/gdkwindow.c: Account for the
+       fact that Xlib expects format == 32 to be a long,
+       even on 64-bit architectures.
+       
+       [ patch from George Lebl (jirka@5z.com) ]
+
+Sun Feb 21 14:46:02 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmain.c (gtk_init_check):
+         gdk/gdk.c     (gdk_init_check):
+
+       Added initialization variants that return a status
+       instead of dying.
+
 Sun Feb 21 14:21:46 1999  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c: removed debugging statements
index 7ccbb7706ef5d5b9e4a72a0f62516244546e3506..0d870f6b055b37b1af07c8dd6a0722387f44a405 100644 (file)
@@ -1,3 +1,19 @@
+Sun Feb 21 15:59:55 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/MwmUtil.h gdk/gdkwindow.c: Account for the
+       fact that Xlib expects format == 32 to be a long,
+       even on 64-bit architectures.
+       
+       [ patch from George Lebl (jirka@5z.com) ]
+
+Sun Feb 21 14:46:02 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmain.c (gtk_init_check):
+         gdk/gdk.c     (gdk_init_check):
+
+       Added initialization variants that return a status
+       instead of dying.
+
 Sun Feb 21 14:21:46 1999  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c: removed debugging statements
index 7ccbb7706ef5d5b9e4a72a0f62516244546e3506..0d870f6b055b37b1af07c8dd6a0722387f44a405 100644 (file)
@@ -1,3 +1,19 @@
+Sun Feb 21 15:59:55 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/MwmUtil.h gdk/gdkwindow.c: Account for the
+       fact that Xlib expects format == 32 to be a long,
+       even on 64-bit architectures.
+       
+       [ patch from George Lebl (jirka@5z.com) ]
+
+Sun Feb 21 14:46:02 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmain.c (gtk_init_check):
+         gdk/gdk.c     (gdk_init_check):
+
+       Added initialization variants that return a status
+       instead of dying.
+
 Sun Feb 21 14:21:46 1999  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c: removed debugging statements
index 7ccbb7706ef5d5b9e4a72a0f62516244546e3506..0d870f6b055b37b1af07c8dd6a0722387f44a405 100644 (file)
@@ -1,3 +1,19 @@
+Sun Feb 21 15:59:55 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/MwmUtil.h gdk/gdkwindow.c: Account for the
+       fact that Xlib expects format == 32 to be a long,
+       even on 64-bit architectures.
+       
+       [ patch from George Lebl (jirka@5z.com) ]
+
+Sun Feb 21 14:46:02 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmain.c (gtk_init_check):
+         gdk/gdk.c     (gdk_init_check):
+
+       Added initialization variants that return a status
+       instead of dying.
+
 Sun Feb 21 14:21:46 1999  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c: removed debugging statements
index 7ccbb7706ef5d5b9e4a72a0f62516244546e3506..0d870f6b055b37b1af07c8dd6a0722387f44a405 100644 (file)
@@ -1,3 +1,19 @@
+Sun Feb 21 15:59:55 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/MwmUtil.h gdk/gdkwindow.c: Account for the
+       fact that Xlib expects format == 32 to be a long,
+       even on 64-bit architectures.
+       
+       [ patch from George Lebl (jirka@5z.com) ]
+
+Sun Feb 21 14:46:02 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmain.c (gtk_init_check):
+         gdk/gdk.c     (gdk_init_check):
+
+       Added initialization variants that return a status
+       instead of dying.
+
 Sun Feb 21 14:21:46 1999  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c: removed debugging statements
index 7ccbb7706ef5d5b9e4a72a0f62516244546e3506..0d870f6b055b37b1af07c8dd6a0722387f44a405 100644 (file)
@@ -1,3 +1,19 @@
+Sun Feb 21 15:59:55 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/MwmUtil.h gdk/gdkwindow.c: Account for the
+       fact that Xlib expects format == 32 to be a long,
+       even on 64-bit architectures.
+       
+       [ patch from George Lebl (jirka@5z.com) ]
+
+Sun Feb 21 14:46:02 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmain.c (gtk_init_check):
+         gdk/gdk.c     (gdk_init_check):
+
+       Added initialization variants that return a status
+       instead of dying.
+
 Sun Feb 21 14:21:46 1999  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c: removed debugging statements
index 7ccbb7706ef5d5b9e4a72a0f62516244546e3506..0d870f6b055b37b1af07c8dd6a0722387f44a405 100644 (file)
@@ -1,3 +1,19 @@
+Sun Feb 21 15:59:55 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/MwmUtil.h gdk/gdkwindow.c: Account for the
+       fact that Xlib expects format == 32 to be a long,
+       even on 64-bit architectures.
+       
+       [ patch from George Lebl (jirka@5z.com) ]
+
+Sun Feb 21 14:46:02 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmain.c (gtk_init_check):
+         gdk/gdk.c     (gdk_init_check):
+
+       Added initialization variants that return a status
+       instead of dying.
+
 Sun Feb 21 14:21:46 1999  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c: removed debugging statements
index 9f4e3a29b2bdd1b3a40114d907efb0b9f5c070d6..53925f685a609db525596abbc2a0b5aab2435bc6 100644 (file)
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  *
+ *
+ * * Feb 21 1999 - George Lebl (jirka@5z.com)
+ *                 Owen Taylor (otaylor@redhat.com)
+ *
+ *   Modified so that the MotifWmHints structure defined here
+ *   is suitable for client side use on 64-bit architectures.
+ *   X expects fields with a format of 32 to be longs, even
+ *   when sizeof(long) == 8.
  **/
 
 #ifndef MWMUTIL_H_INCLUDED
@@ -33,11 +41,11 @@ extern "C" {
 #endif
 
 typedef struct {
-    CARD32 flags;
-    CARD32 functions;
-    CARD32 decorations;
-    INT32 input_mode;
-    CARD32 status;
+    unsigned long flags;
+    unsigned long functions;
+    unsigned long decorations;
+    long input_mode;
+    unsigned long status;
 } MotifWmHints, MwmHints;
 
 #define MWM_HINTS_FUNCTIONS     (1L << 0)
@@ -100,11 +108,11 @@ typedef MotifWmInfo MwmInfo;
  * _MWM_HINTS property
  */
 typedef struct {
-    CARD32 flags;
-    CARD32 functions;
-    CARD32 decorations;
-    INT32 inputMode;
-    CARD32 status;
+    unsigned long flags;
+    unsigned long functions;
+    unsigned long decorations;
+    long inputMode;
+    unsigned long status;
 } PropMotifWmHints;
 
 typedef PropMotifWmHints PropMwmHints;
@@ -116,8 +124,8 @@ typedef PropMotifWmHints PropMwmHints;
  * _MWM_INFO property, slight return
  */
 typedef struct {
-    CARD32 flags;
-    CARD32 wmWindow;
+    unsigned long flags;
+    unsigned long wmWindow;
 } PropMotifWmInfo;
 
 typedef PropMotifWmInfo PropMwmInfo;
index f4d5f7b8084da6b5055a179d8f7205b5f033885e..f10a89830866a32490d92391054e36054ad3e506 100644 (file)
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -124,7 +124,7 @@ static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);
 
 /*
  *--------------------------------------------------------------
- * gdk_init
+ * gdk_init_heck
  *
  *   Initialize the library for use.
  *
@@ -135,7 +135,8 @@ static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);
  * Results:
  *   "argc" and "argv" are modified to reflect any arguments
  *   which were not handled. (Such arguments should either
- *   be handled by the application or dismissed).
+ *   be handled by the application or dismissed). If initialization
+ *   fails, returns FALSE, otherwise TRUE.
  *
  * Side effects:
  *   The library is initialized.
@@ -143,9 +144,9 @@ static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);
  *--------------------------------------------------------------
  */
 
-void
-gdk_init (int   *argc,
-         char ***argv)
+gboolean
+gdk_init_check (int     *argc,
+               char ***argv)
 {
   XKeyboardState keyboard_state;
   gint synchronize;
@@ -155,7 +156,7 @@ gdk_init (int        *argc,
   gint argc_orig = 0;
   
   if (gdk_initialized)
-    return;
+    return TRUE;
   
   if (g_thread_supported ())
     gdk_threads_mutex = g_mutex_new ();
@@ -370,10 +371,7 @@ gdk_init (int       *argc,
   
   gdk_display = XOpenDisplay (gdk_display_name);
   if (!gdk_display)
-    {
-      g_warning ("cannot open display: %s", XDisplayName (gdk_display_name));
-      exit(1);
-    }
+    return FALSE;
   
   if (synchronize)
     XSynchronize (gdk_display, True);
@@ -428,6 +426,18 @@ gdk_init (int       *argc,
 #endif
   
   gdk_initialized = 1;
+
+  return TRUE;
+}
+
+void
+gdk_init (int *argc, char ***argv)
+{
+  if (!gdk_init_check (argc, argv))
+    {
+      g_warning ("cannot open display: %s", gdk_get_display ());
+      exit(1);
+    }
 }
 
 /*
index b8b84a099bfd4fe91a50be3532ff6db519865f8f..113711b06b757fcd4991e3545c004271c3eadb78 100644 (file)
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -32,6 +32,8 @@ extern "C" {
 #define          GDK_PRIORITY_EVENTS           (G_PRIORITY_DEFAULT)
 void     gdk_init                      (gint           *argc,
                                         gchar        ***argv);
+gboolean  gdk_init_check               (gint           *argc,
+                                        gchar        ***argv);
 void     gdk_exit                      (gint            error_code);
 gchar*   gdk_set_locale                (void);
 
index c2b89445351901430afe16e096648214be2a1cb6..32ced4397ef365a6f72dec1809b27c3ee798f23e 100644 (file)
@@ -2131,7 +2131,7 @@ gdk_window_set_mwm_hints (GdkWindow *window,
                              _XA_MOTIF_WM_HINTS, FALSE);
   
   XGetWindowProperty (window_private->xdisplay, window_private->xwindow,
-                     hints_atom, 0, sizeof (MotifWmHints)/4,
+                     hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
                      False, AnyPropertyType, &type, &format, &nitems,
                      &bytes_after, (guchar **)&hints);
   
@@ -2153,7 +2153,7 @@ gdk_window_set_mwm_hints (GdkWindow *window,
   
   XChangeProperty (window_private->xdisplay, window_private->xwindow,
                   hints_atom, hints_atom, 32, PropModeReplace,
-                  (guchar *)hints, sizeof (MotifWmHints)/4);
+                  (guchar *)hints, sizeof (MotifWmHints)/sizeof (long));
   
   if (hints != new_hints)
     XFree (hints);
index 9f4e3a29b2bdd1b3a40114d907efb0b9f5c070d6..53925f685a609db525596abbc2a0b5aab2435bc6 100644 (file)
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  *
+ *
+ * * Feb 21 1999 - George Lebl (jirka@5z.com)
+ *                 Owen Taylor (otaylor@redhat.com)
+ *
+ *   Modified so that the MotifWmHints structure defined here
+ *   is suitable for client side use on 64-bit architectures.
+ *   X expects fields with a format of 32 to be longs, even
+ *   when sizeof(long) == 8.
  **/
 
 #ifndef MWMUTIL_H_INCLUDED
@@ -33,11 +41,11 @@ extern "C" {
 #endif
 
 typedef struct {
-    CARD32 flags;
-    CARD32 functions;
-    CARD32 decorations;
-    INT32 input_mode;
-    CARD32 status;
+    unsigned long flags;
+    unsigned long functions;
+    unsigned long decorations;
+    long input_mode;
+    unsigned long status;
 } MotifWmHints, MwmHints;
 
 #define MWM_HINTS_FUNCTIONS     (1L << 0)
@@ -100,11 +108,11 @@ typedef MotifWmInfo MwmInfo;
  * _MWM_HINTS property
  */
 typedef struct {
-    CARD32 flags;
-    CARD32 functions;
-    CARD32 decorations;
-    INT32 inputMode;
-    CARD32 status;
+    unsigned long flags;
+    unsigned long functions;
+    unsigned long decorations;
+    long inputMode;
+    unsigned long status;
 } PropMotifWmHints;
 
 typedef PropMotifWmHints PropMwmHints;
@@ -116,8 +124,8 @@ typedef PropMotifWmHints PropMwmHints;
  * _MWM_INFO property, slight return
  */
 typedef struct {
-    CARD32 flags;
-    CARD32 wmWindow;
+    unsigned long flags;
+    unsigned long wmWindow;
 } PropMotifWmInfo;
 
 typedef PropMotifWmInfo PropMwmInfo;
index f4d5f7b8084da6b5055a179d8f7205b5f033885e..f10a89830866a32490d92391054e36054ad3e506 100644 (file)
@@ -124,7 +124,7 @@ static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);
 
 /*
  *--------------------------------------------------------------
- * gdk_init
+ * gdk_init_heck
  *
  *   Initialize the library for use.
  *
@@ -135,7 +135,8 @@ static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);
  * Results:
  *   "argc" and "argv" are modified to reflect any arguments
  *   which were not handled. (Such arguments should either
- *   be handled by the application or dismissed).
+ *   be handled by the application or dismissed). If initialization
+ *   fails, returns FALSE, otherwise TRUE.
  *
  * Side effects:
  *   The library is initialized.
@@ -143,9 +144,9 @@ static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);
  *--------------------------------------------------------------
  */
 
-void
-gdk_init (int   *argc,
-         char ***argv)
+gboolean
+gdk_init_check (int     *argc,
+               char ***argv)
 {
   XKeyboardState keyboard_state;
   gint synchronize;
@@ -155,7 +156,7 @@ gdk_init (int        *argc,
   gint argc_orig = 0;
   
   if (gdk_initialized)
-    return;
+    return TRUE;
   
   if (g_thread_supported ())
     gdk_threads_mutex = g_mutex_new ();
@@ -370,10 +371,7 @@ gdk_init (int       *argc,
   
   gdk_display = XOpenDisplay (gdk_display_name);
   if (!gdk_display)
-    {
-      g_warning ("cannot open display: %s", XDisplayName (gdk_display_name));
-      exit(1);
-    }
+    return FALSE;
   
   if (synchronize)
     XSynchronize (gdk_display, True);
@@ -428,6 +426,18 @@ gdk_init (int       *argc,
 #endif
   
   gdk_initialized = 1;
+
+  return TRUE;
+}
+
+void
+gdk_init (int *argc, char ***argv)
+{
+  if (!gdk_init_check (argc, argv))
+    {
+      g_warning ("cannot open display: %s", gdk_get_display ());
+      exit(1);
+    }
 }
 
 /*
index c2b89445351901430afe16e096648214be2a1cb6..32ced4397ef365a6f72dec1809b27c3ee798f23e 100644 (file)
@@ -2131,7 +2131,7 @@ gdk_window_set_mwm_hints (GdkWindow *window,
                              _XA_MOTIF_WM_HINTS, FALSE);
   
   XGetWindowProperty (window_private->xdisplay, window_private->xwindow,
-                     hints_atom, 0, sizeof (MotifWmHints)/4,
+                     hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
                      False, AnyPropertyType, &type, &format, &nitems,
                      &bytes_after, (guchar **)&hints);
   
@@ -2153,7 +2153,7 @@ gdk_window_set_mwm_hints (GdkWindow *window,
   
   XChangeProperty (window_private->xdisplay, window_private->xwindow,
                   hints_atom, hints_atom, 32, PropModeReplace,
-                  (guchar *)hints, sizeof (MotifWmHints)/4);
+                  (guchar *)hints, sizeof (MotifWmHints)/sizeof (long));
   
   if (hints != new_hints)
     XFree (hints);
index 8e2a2f32411b95d42b2dcb449b3ebf950b8c70e2..e5763e5193d56fc1d4ef0f8f53a16a9f69c0c766 100644 (file)
@@ -166,16 +166,16 @@ gtk_check_version (guint required_major,
 }
 
 
-void
-gtk_init (int   *argc,
-         char ***argv)
+gboolean
+gtk_init_check (int     *argc,
+               char   ***argv)
 {
   GSList *gtk_modules = NULL;
   GSList *slist;
   gchar *env_string = NULL;
 
   if (gtk_initialized)
-    return;
+    return TRUE;
 
 #if    0
   g_set_error_handler (gtk_error);
@@ -187,7 +187,8 @@ gtk_init (int        *argc,
   /* Initialize "gdk". We pass along the 'argc' and 'argv'
    *  parameters as they contain information that GDK uses
    */
-  gdk_init (argc, argv);
+  if (!gdk_init_check (argc, argv))
+    return FALSE;
 
   gdk_event_handler_set ((GdkEventFunc)gtk_main_do_event, NULL, NULL);
   
@@ -401,6 +402,18 @@ gtk_init (int       *argc,
        }
     }
   g_slist_free (gtk_modules);
+
+  return TRUE;
+}
+
+void
+gtk_init (int *argc, char ***argv)
+{
+  if (!gtk_init_check (argc, argv))
+    {
+      g_warning ("cannot open display: %s", gdk_get_display ());
+      exit(1);
+    }
 }
 
 void
index b44489f89fa8dec00f53504880144a0a50513100..2f07e6cb093d6a3911e6ff10269317bd08e182a0 100644 (file)
@@ -62,6 +62,8 @@ gchar* gtk_check_version (guint       required_major,
  */
 void      gtk_init              (int          *argc,
                                  char       ***argv);
+gboolean   gtk_init_check        (int         *argc,
+                                 char       ***argv);
 void      gtk_exit              (gint          error_code);
 gchar*    gtk_set_locale        (void);
 gint      gtk_events_pending    (void);